// 使用 Mock
var Mock = require('mockjs')

Mock.mock('/user/login',function() {
    return {
        status:"success",
        message:"登陆成功",
        data:{
            userid:1,
            username:"邓渊",
            icon:"",
            position:"ceo"
        }
    }
})

Mock.mock('/enterprise/departmenttree',function() {
    return {
        id:1,
        number:5,
        name:'南云信息',
        children:[
            {
                id:1,
                number:1,
                name:'总经办',
                users:[
                    {
                        userid:1,
                        departmentid:1,
                        name:'邓渊',
                        icon:'',
                        position:'CEO',
                    },
                ]
            },
            {
                id:2,
                number:1,
                name:'财务部',
                users:[
                    {
                        userid:2,
                        departmentid:2,
                        name:'王红',
                        icon:'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2873483837,2884488065&fm=26&gp=0.jpg',
                        position:'财务经理'
                    },
                ]
            },
            {
                id:6,
                number:2,
                name:'技术部',
                children:[
                    {
                        id:61,
                        number:1,
                        name:'前端',
                        users:[
                            {
                                userid:3,
                                departmentid:61,
                                name:'王志刚',
                                icon:'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4052667666,3811234810&fm=26&gp=0.jpg',
                                position:'前端leader'
                            }
                        ]
                    },
                    {
                        id:62,
                        number:1,
                        name:'后端',
                        users:[
                            {
                                userid:4,
                                departmentid:62,
                                name:'王文波',
                                icon:'',
                                position:'后端leader'
                            }
                        ]
                    },
                ]
            },
            {
                id:7,
                number:1,
                name:'保安部',
                users:[
                    {
                        userid:5,
                        departmentid:72,
                        name:'于坤',
                        icon:'',
                        position:'保安队长'
                    }
                ]
            },
        ]
    };
});

Mock.mock('/order/list',function() {
    return [
        {
            index:0,
            title:'考勤流程',
            itemlist:[
                {
                    templateid:11,
                    icon:'iconiconzhengli_qingjia',
                    name:'请假申请'
                },
                {
                    templateid:12,
                    icon:'iconjiaban',
                    name:'加班申请'
                },
                {
                    templateid:13,
                    icon:'icontiaoxiushenqing1',
                    name:'调休申请'
                },
                {
                    templateid:14,
                    icon:'iconchuchalvyouchuxing',
                    name:'出差申请'
                }, 
            ]
        },
        {
            index:1,
            title:'人事流程',
            itemlist:[
                {
                    templateid:21,
                    icon:'icontubiaozhizuomoban-96',
                    name:'用人申请'
                },
                {
                    templateid:22,
                    icon:'iconzhuanzheng',
                    name:'转正申请'
                },
                {
                    templateid:23,
                    icon:'iconzhuanzhengdiaogangzhuangang',
                    name:'转岗申请'
                },
                {
                    templateid:14,
                    icon:'iconlizhi',
                    name:'离职申请'
                }, 
                {
                    templateid:15,
                    icon:'iconlizhijiaojie1',
                    name:'离职交接申请'
                }, 
            ]
        },
    ]
})


Mock.mock('/template/get',function(params) {
    let body = JSON.parse(params.body);
    let templateid = body.templateid;
    let data = [
        {
            templateid:11,
            title:'请假申请',
            list:[
                {
                    id:1,
                    title:'请假类型',
                    placeholder:'请选择请假类型',
                    isRequired:true,
                    type:'select',
                    model:'',
                    showPicker: false,
                    columns: ['事假','病假','年假','产假','其他'],
                },
                {
                    id:2,
                    title:'开始时间',
                    placeholder:'请选择开始时间',
                    isRequired:true,
                    type:'datetime',
                    showPicker:false,
                    model:'',
                },
                {
                    id:3,
                    title:'结束时间',
                    placeholder:'请选择结束时间',
                    isRequired:true,
                    type:'datetime',
                    showPicker:false,
                    model:'',
                },
                {
                    id:4,
                    title:'请假时长',
                    placeholder:'请输入请假时长',
                    isRequired:true,
                    type:'text',
                    model:'',
                },
                {
                    id:5,
                    title:'请假事由',
                    placeholder:'请输入请假事由',
                    isRequired:true,
                    type:'textarea',
                    model:'',
                },
                {
                    id:6,
                    title:'图片',
                    icon:'',
                    isRequired:true,
                    placeholder:'请上传图片',
                    type:'picture',
                    multiple:false,
                    model:'',
                    fileList: [],
                   
                },
                {
                    id:7,
                    title:'审批人',
                    icon:'',
                    isRequired:true,
                    type:'examiner',
                    placeholder:'请选择审批人',
                    model:'',
                    users:[]
                },
                {
                    id:8,
                    title:'执行人',
                    icon:'',
                    isRequired:false,
                    type:'executor',
                    model:'',
                    users:[]
                },
                {
                    id:9,
                    title:'抄送人',
                    icon:'',
                    isRequired:false,
                    type:'copyperson',
                    model:'',
                    users:[]
                },
            ]
        },
        {
            templateid:12,
            title:'加班申请',
            list:[
                {
                    id:1,
                    title:'开始时间',
                    placeholder:'请选择开始时间',
                    isRequired:true,
                    type:'datetime',
                    showPicker:false,
                    model:'',
                },
                {
                    id:2,
                    title:'结束时间',
                    placeholder:'请选择结束时间',
                    isRequired:true,
                    type:'datetime',
                    showPicker:false,
                    model:'',
                },
                {
                    id:6,
                    title:'图片',
                    icon:'',
                    isRequired:true,
                    placeholder:'请上传图片',
                    type:'picture',
                    multiple:false,
                    model:'',
                    fileList: [],
                   
                },
                {
                    id:3,
                    title:'审批人',
                    icon:'',
                    isRequired:true,
                    type:'examiner',
                    placeholder:'请选择审批人',
                    model:'',
                    users:[]
                },
                {
                    id:4,
                    title:'执行人',
                    icon:'',
                    isRequired:false,
                    type:'executor',
                    model:'',
                    users:[]
                },
            ]
        }
    ]
    for(let item of data) {
        if(item.templateid === templateid) {
            return {
                status:'success',
                data:item
            };
        }
    }
    return {
        status:'error',
        message:'该流程模板未配置'
    };
});

